<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ page contentType="text/html; charset=utf-8" %>
<%@	page import="java.io.*"%>
<%@page import="java.net.*"%>
<%@	page import="java.awt.Image"%>
<%@	page import="javax.imageio.ImageIO"%>
<%@	page import="java.awt.image.BufferedImage"%>
<%@page import="com.opensymphony.xwork2.util.ValueStack"%>
<%
	request.setCharacterEncoding("UTF-8");
	ValueStack vs = (ValueStack)request.getAttribute("struts.valueStack");
	File exportFile = (File)vs.findValue("exportFile");
	String fileName = exportFile.getName();
		response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
		String fn = fileName.substring(0,fileName.lastIndexOf("."));
		response.setHeader("Content-disposition","attachment; filename="+  new String( fileName.getBytes("UTF-8"), "ISO8859-1" ) );
		
		BufferedInputStream bis = null;
		BufferedOutputStream bos = null;
		FileInputStream fis=null;
		try {
			fis=new FileInputStream(exportFile);
		    bis = new BufferedInputStream(fis);
	    	bos = new BufferedOutputStream(response.getOutputStream());
	    	
		    byte[] buff = new byte[2048];
		    int bytesRead;
		
		    while(-1 != (bytesRead = bis.read(buff, 0, buff.length))) {
		    	bos.write(buff,0,bytesRead);
		    }
		} catch(final IOException e) {
		    System.out.println ( "出现IOException." + e );
		} finally {
			if (fis!=null){
				fis.close();
			}
		    if (bis != null){
		    	bis.close();	    	
		    } 
		    if (bos != null){
		    	bos.close();	 
		    }
		    out.clear(); 
		    out=pageContext.pushBody();     
		}
%>